home *** CD-ROM | disk | FTP | other *** search
/ HyperLib 1997 Winter - Disc 1 / HYPERLIB-1997-Winter-CD1.ISO.7z / HYPERLIB-1997-Winter-CD1.ISO / オンラインウェア / COM / LineShare 3.3.1 folder.sit / LineShare 3.3.1 folder / LineShare 3.3.1 / LineShare Scripts / Zoom Fax1&ARA&Data < prev    next >
Text File  |  1994-10-06  |  8KB  |  383 lines

  1. ! Version 3.0
  2. !
  3. !$ Use this script with Rockwell-based (Zoom, Hayes Optima, etc)
  4. !$ data/fax modems.
  5. !$ Supports: fax, ARA and regular data incoming calls.
  6. !
  7. !$ Make sure that *Class 1* fax software is installed
  8. !
  9. !$ A cable for hardware handshaking is required
  10.  
  11. ^2 Speaker On:        = Enum("Never" = "0","During Connect" = "1", "Always"="2") "1"
  12. ^3 Speaker Volume:       = Enum("Low"="1","Medium"="2","High"="3") "2"
  13. ^4 Answer On:         = Enum("1 Ring"="1","2 Rings"="2","3 Rings"="3","5 Rings"="5","7 Rings"="7") "2"
  14. ^5 Port Speed:        = Enum("9600","19200","38400","57600") "19200"
  15. ^6 Handshake wires:   = Bool("Both"="&D0","CTS only"="&D2") "&D2"
  16. ! ------------------------------------------
  17. ! Resetting the modem:
  18. ! ------------------------------------------
  19. @Hangup
  20.   SetTries 2
  21.   Flush
  22.   HsReset 0,0,17,19,0,0
  23.   DtrSet
  24. !
  25. ! Try to catch the "OK" answer, use the Escape seq and DTR transitions
  26. ! to enter the command mode
  27. !
  28. @Label 1
  29.   matchclr
  30.   matchstr 1 2 "OK¥r¥n"
  31.   write "ATH0&F¥r"
  32.   matchread 20
  33.   ChrDelay 1
  34.   Write "+++"
  35.   ChrDelay 0
  36.   DtrClear
  37.   SBreak
  38.   DtrSet
  39. !
  40.   DecTries
  41.   IfTries 0 1
  42. !
  43. ! OSErr -6019 "Modem error - the modem is not responding"
  44. !
  45.   exit -6019
  46. @Label 2
  47.   write "AT+FCLASS=0¥r"
  48.   Jsr 100
  49.   write "AT+FAE=0¥r"
  50.   Jsr 100
  51.   exit 0
  52.  
  53. ! ------------------------------------------
  54. !    Receiving incoming calls
  55. ! ------------------------------------------
  56. @ANSWER
  57. !
  58. ! Set the modem preferred speed first
  59. !
  60.   SerReset Val("^5"),0,8,1
  61.   Jsr 80
  62.  
  63. @Label 10
  64. !
  65. ! Set the common options
  66.   Jsr 70
  67. !
  68. ! Set the communication options:
  69. ! ・ &Q6: Normal connection (for ARA)
  70. ! ・ &K4: SW flow control   (for fax)
  71. ! ・ W1:  report connection speed
  72. !
  73.   Write "AT&Q6&K4W1¥r"
  74.   Jsr 100
  75. !
  76. ! Set Fax mode
  77. !
  78.   Write "AT+FCLASS=1¥r"
  79.   Jsr 100
  80.   Write "AT+FAE=1¥r"
  81.   Jsr 100
  82. !
  83. ! It's for Rockwell ONLY! Set FCLASS to 0 again - otherwise,
  84. ! it cannot accept data calls
  85. !
  86.   Write "AT+FCLASS=0¥r"
  87.   Jsr 100
  88. !
  89. ! Tell the modem to determine the type of the incoming call
  90. ! Fetch the tube after ^4 rings
  91. !
  92.   Write "ATS0=^4V0¥r"
  93.   Jsr 110
  94. !
  95. ! Everything is ready - let's sit and wait for a call
  96. ! We'll wait for 2 minutes, then reinitiate the modem
  97. !
  98.   Note "Waiting for a fax/ARA/data callノ"
  99.   MatchClr
  100.   MatchStr 01 19 "33¥r"
  101.   MatchStr 02 14 "35¥r"
  102.   matchstr 10 18 "2¥r"
  103.   matchstr 11 57 "1¥r"
  104.   matchstr 12 13 "3¥r"
  105.   matchstr 13 13 "8¥r"
  106.   matchstr 14 13 "7¥r"
  107. @Label 12
  108.   Matchread 1200
  109. @Label 13
  110.   Note "Tuning againノ"
  111.   Write "ATV1¥r"
  112.   Jsr 100
  113.   Jump 10
  114.  
  115. @Label 14
  116.   Note "Data Callノ"
  117.   Write "AT&K3W1V1O0¥r"
  118.   MatchClr
  119.   MatchStr 01 16 "CARRIER ^$¥r¥n"
  120.   MatchStr 02 20 "CONNECT ^$¥r¥n"
  121.   MatchStr 03 10 "NO ANSWER¥r¥n"
  122.   MatchStr 04 10 "NO CARRIER¥r¥n"
  123. @Label 15
  124.   MatchRead 20
  125.   Exit -6019
  126.  
  127. @Label 16
  128.   SetVar B "^$"
  129.   Jump 15
  130.  
  131. @Label 18
  132.   Note "Ringノ"
  133.   Jump 12
  134. @Label 19
  135.   SetSpeed 19200
  136.   Note "Fax tones detectedノ"
  137.   Jump 12
  138.  
  139. !
  140. ! Data connection has been established (we read "CONNECT")
  141. ! Put the "CONNECT" back to the buffer and attach the "Data" subPort
  142. ! if it was an incoming call, put the "RING" before the "CONNECT"
  143. !
  144. @Label 20
  145.   IfOpen "Data" 21
  146.   Jump 30
  147. @Label 21
  148.   IfOpen "ARA" 22
  149.   Jump 35
  150. @Label 22
  151.   Note "Waiting for an ARA frame"
  152.   MatchClr
  153.   MatchStr 1 23 "^$¥r"
  154.   MatchStr 2 28 "¥08¥01¥03¥14¥04¥03¥00¥08¥250¥16¥03"
  155.   MatchStr 3 29 "¥01¥27¥02¥29¥01¥02¥01¥06"
  156.   MatchRead 60
  157.   Jump 24
  158. @Label 23
  159.   QueueInput "^$¥r"
  160. @Label 24
  161.   Note "Non-ARA call"
  162.   Jump 35
  163.  
  164. @Label 28
  165.   Note "ARA 1.0 call"
  166.   Jump 30
  167. @Label 29
  168.   Note "ARA 2.0 call"
  169.   Jump 30
  170.  
  171. @Label 30
  172.   QueueInput "¥r¥nCARRIER ^B¥r¥n"  
  173.   QueueInput "¥r¥nRING¥r¥n"
  174.   Attach "ARA" (DTR)
  175.  
  176. @Label 35
  177.   GetSReg C "DATA" 4
  178.   QueueInput "¥r^CCONNECT ^B¥r^C"
  179.   ifOriginate 36
  180.   QueueInput "¥r^CRING¥r^C"
  181. @Label 36
  182.   Attach "Data" (DTR,Escape,Break)
  183.  
  184. ! ------------------------------------------
  185. ! Originating a call through the "ARA" subport
  186. ! ------------------------------------------
  187. @ORIGINATE "ARA"
  188.   SerReset Val("^5"),0,8,1
  189.   Jsr 80
  190. !
  191. ! Set the common options
  192. !
  193.   Jsr 70
  194. !
  195. ! Set the Data mode:
  196. ! ・ &Q6:Normal connection (no compression, correction - for ARA)
  197. ! ・ &K3: HW Handshake
  198. ! ・ハS7:  time-out (90 sec) for long-distance call (if you use them)
  199. ! ・ W1:  report connection rate
  200. !
  201.   Write "AT&Q6&K3S7=90W1¥r"
  202.   Jsr 100
  203. !
  204. ! Emit the ARA script commands ("Xnn")
  205.   Jsr 60
  206. !
  207. ! Prepare to receive all error result codes, dial the number
  208. !
  209.   Jsr 90
  210.   MatchStr 1 55 "¥r¥nCARRIER "
  211.   MatchRead 1000
  212.   Write "¥r"
  213.   Exit -6019
  214. @Label 55
  215.   QueueInput "¥r¥nCARRIER "
  216.   Attach "ARA" (DTR)
  217.  
  218. ! ------------------------------------------
  219. ! Originating a call through the "DATA" subport
  220. ! ------------------------------------------
  221. @ORIGINATE "Data"
  222.   SerReset Val("^5"),0,8,1
  223.   Jsr 80
  224. !
  225. ! Set the common options
  226. !
  227.   Jsr 70
  228. !
  229. ! Set the Data mode:
  230. ! ・ ¥N3: Auto-reliable
  231. ! ・ &K3: HW Handshake
  232. ! ・ハS7:  time-out (90 sec) for long-distance call (if you use them)
  233. !
  234.   Write "AT&K3S7=90¥r"
  235.   Jsr 100
  236. !
  237. ! Emit the Data commands
  238.   Jsr 60
  239. !
  240. ! Prepare to receive all error result codes, dial the number
  241. !
  242.   Jsr 90
  243.   MatchStr 1 56 "¥r¥nCONNECT "
  244.   MatchRead 1000
  245.   Write "¥r"
  246.   Exit -6019
  247. @Label 56
  248.   QueueInput "¥r¥nCONNECT "
  249.   Attach "Data" (DTR,Escape,Break)
  250.  
  251. ! ------------------------------------------
  252. ! Originating a call through the "Fax" subPort
  253. ! ------------------------------------------
  254. @ORIGINATE "Fax"
  255. !
  256. ! Set the "Fax" speed
  257. !
  258.   SerReset 19200,0,8,1
  259.   Jsr 80
  260. !
  261. ! Set the common options
  262. !
  263.   Jsr 70
  264. !
  265. ! Set the Fax mode
  266. ! &K4: Xon/Xoff handshake
  267. ! &S0: DSR always on (see above)
  268. !
  269.   Write "AT&S0&K4+FCLASS=1¥r"
  270.   Jsr 100
  271. !
  272. ! Now emit all commands that the application has sent to that port,
  273. ! except "FCLASS", etc
  274. !
  275.   EmitClear "+FCLASS","V","E"
  276.   Jsr 60
  277.   Write "ATV0¥r"
  278.   Jsr 110
  279. !
  280. ! Prepare to receive all error result codes, dial the number
  281. !
  282.   MatchClr
  283.   MatchStr 01 57 "1¥r"
  284.   MatchStr 13 93 "3¥r"
  285.   MatchStr 14 94 "8¥r"
  286.   MatchStr 15 92 "7¥r"
  287.   Write "ATD^1¥r"
  288.   HsReset *
  289.   MatchRead 900
  290.   Write "¥r"
  291.   Exit -6019
  292.  
  293. !
  294. ! Fax connection has been established (we read "FAX")
  295. ! Put the +FCON back to the buffer,
  296. ! if it was an incoming call, put the "RING" before the "+FCON"
  297. ! Attach the "Fax" subPort
  298. !
  299. @Label 57
  300.   QueueInput "1¥r"
  301.   SetSpeed 19200
  302.   ifOriginate 59
  303. !@Label 58
  304.   QueueInput "2¥r2¥r"
  305. @Label 59
  306.   Attach "Fax" (Reset(2400),IdleLimit=30)
  307.  
  308. !
  309. ! This section emits all modem commands sent from the client application
  310. ! For each set of commands the "OK" answer is awaited
  311. !
  312. @Label 60
  313.   EmitStart
  314. @Label 61
  315.   EmitCommand 62
  316.   Jsr 100
  317.   Jump 61
  318. @Label 62
  319.   return
  320. !
  321. ! This section initiates the modem before ANSWER and ORIGINATEs:
  322. ! extended responses + connect at the highest rate + speaker control +
  323. ! reset on Dtr drop + DCD valid
  324. ! Verbal responses mode, no echo 
  325. !
  326. @Label 70
  327.   Write "ATX4N1M^2L^3^6&C1V1E0¥r"
  328.   Jsr 100
  329.   return 
  330.  
  331. !
  332. ! This section syncronize the modem after the serial port speed switching
  333. !
  334. @Label 80
  335.   ChrDelay 1
  336.   Write "AT¥r"
  337.   ChrDelay 0
  338.   Jsr 100
  339.   return
  340. !
  341. ! Prepare to receive error result codes, send the dialing command and
  342. ! set the user's handshake mode
  343. !
  344. @Label 90
  345.   MatchClr
  346.   MatchStr 2 91 "NO DIALTONE¥r¥n"
  347.   MatchStr 3 92 "BUSY¥r¥n"
  348.   MatchStr 4 93 "NO CARRIER¥r¥n"
  349.   MatchStr 5 94 "NO ANSWER¥r¥n"
  350.   Write "ATD^1¥r"
  351.   HsReset *
  352.   return
  353. @Label 91
  354.   exit -6020
  355. @Label 92
  356.   exit -6022
  357. @Label 93
  358.   exit -6021
  359. @Label 94
  360.   exit -6023
  361. !
  362. ! Processing the AT command:
  363. ! OK -> proceed
  364. ! ERROR or TimeOut ->exit -6019
  365. ! It can be called AFTER the "Write" command, since LineShare buffers input
  366. !
  367. @Label 100
  368.   MatchClr
  369.   MatchStr 1 103 "¥r¥nOK¥r¥n"
  370.   MatchStr 2 102 "¥r¥nERROR¥r¥n"
  371. @Label 101
  372.   MatchRead 20
  373. @Label 102
  374.   Exit -6019
  375. @Label 103
  376.   return
  377.  
  378. @Label 110
  379.   MatchClr
  380.   MatchStr 1 103 "0¥r"
  381.   MatchStr 2 102 "4¥r"
  382.   Jump 101
  383.